
/**
 * @author LKQ
 * @date 2022/3/8 16:31
 * @description 深度优先遍历
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int countNodes(TreeNode root) {
        if(root == null) {
            return 0;
        }
        return countNodes(root.left) + countNodes(root.right) + 1;
    }
}
